<include file="Public/header" /> 

<!--主窗体-->
<div class="container app">
	<!--左侧菜单-->
	<include file="Public/sidebar" /> 
	<!--左侧菜单//-->
	
	<!-- mainCon -->
	<div id="mainCon" class="mainCon">
		<h4><{$defSubTitle|default="编辑文章"}></h4>
		<form class="form-horizontal" id="myform" name="myform">
			<div class="form-group">
				<label for="title" class="col-sm-2 control-label">文章标题</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="title" id="title" value="<{$data['title']}>" placeholder="文章标题">
				</div>
			</div>

			<div class="form-group">
				<label for="cid" class="col-sm-2 control-label">所属栏目</label>
				<div class="col-sm-5">
					<select class="form-control" name="cid">
  						<option value="0">-请选择栏目-</option>
  						<foreach name="cate" item="vo">
  							<option value="<{$vo['id']}>" <if condition="$data['cat_id'] eq $vo['id']">selected</if>><{$vo['cat_name']}></option>
  						</foreach>
  					</select>
				</div>
			</div>
			
			<div class="form-group">
				<label for="taxis" class="col-sm-2 control-label">排序</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="taxis" id="taxis" value="<{$data['taxis']|default="100"}>" placeholder="自定义排序，值越大越靠前.">
				</div>
			</div>

			<div class="form-group">
				<label for="seo_key" class="col-sm-2 control-label">文章SEO关键字</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="seo_key" id="seo_key" value="<{$data['seo_key']}>" placeholder="文章SEO关键字">
				</div>
			</div>

			<div class="form-group">
				<label for="seo_depict" class="col-sm-2 control-label">文章SEO描述</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="seo_depict" id="seo_depict" value="<{$data['seo_depict']}>" placeholder="文章SEO描述">
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">是否显示</label>
				<div class="radio col-sm-5">
					<label>
						<input type="radio" name="status" id="status1" value="1" <if condition="$data['status'] eq 1">checked</if>>
					   	显示
					</label>
					<label>
						<input type="radio" name="status" id="status0" value="0" <if condition="$data['status'] eq 0">checked</if>>
					   	隐藏
					</label>
				</div>
			</div>
			
			<div class="form-group">
				<label for="title" class="col-sm-2 control-label">文章内容</label>
				<div class="col-sm-5">
					<textarea name="content" id="content" style="width:680px;height:480px;font-size:16px;"><{$data['content']}></textarea>
					<{:A('Editor')->buildEditor('content');}>
				</div>
			</div>
			
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="id" value="<{$data['id']}>"/>
					<button type="submit" class="btn btn-default col-sm-2">保存</button>
				</div>
			</div>
		</form>
		
	</div>
	<!-- mainCon// -->
	
</div>
<!--主窗体//-->

<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/validate/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/validate/messages_zh.js"></script>
<script>
$(function(){
	
	$('#taxis').on('click', function(){
	    var that = this;
	    layer.tips('自定义排序，值越大越靠前.', that, {
		    tips: [2, '#3595CC'],
		});
	});

	$('#seo_key').focus(function() {
		var index = layer.tips('用逗号[英文半角]分隔,字数推荐20字以内',"#seo_key",{time:0});
		$(this).blur(function() {
			layer.close(index);
		});
	});

	$('#seo_depict').focus(function() {
		var index = layer.tips('字数推荐150字以内',"#seo_depict",{time:0});
		$(this).blur(function() {
			layer.close(index);
		});
	});
	
	$("#myform").validate({
		rules: {
			title : {
				required : true
            },
            cid : {
            	min:1
            }
		},
		messages: {
			cid : {
				min : "请选择栏目"
			}
		},
		submitHandler : function(form){
			<if condition="C('editor') eq 'ueditor'">
			ue.sync("myform");
			</if>
			var ajaxUrl = "<{$ajaxUrl ? $ajaxUrl : U('Admin/ArticleSite/do_articleEdit')}>";
			 $.post(ajaxUrl,$("#myform").serialize(),function(r){
    			if (r.error == 1){
    				layer.alert(r.errmsg,{icon: 2});
    			}else{
    				layer.alert(r.errmsg,{icon: 1},function(){
    					window.location.href = "<{:U('Admin/articleSite/articleList',array('k'=>1,'sk'=>0))}>";
    				});
    			}
    			return false;
    		});
        	return false
		}
	});
});
</script>

<include file="Public/footer" /> 